﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iCollect.CustomComponent;
using System.Windows.Forms;
using iCollect.Constants;
using iCollect.CollectDetail;

namespace iCollect.util
{
    class UIUtil
    {
        private static UIUtil uiUtil;
        public static UIUtil getInstance()
        {
            if (uiUtil == null)
            {
                uiUtil = new UIUtil();
            }
            return uiUtil;
        }

        public delegate void Del(object sender, System.EventArgs a);

        public BaseDeviceSample loadSample(BaseDeviceSample ds, Panel panel2, EventHandler del)
        {
            panel2.Controls.Remove(ds);
            if (GlobalConstants.type == "0")
            {
                ds = new DeviceSample();

            }
            else if (GlobalConstants.type == "1")
            {
                ds = new Device2Sample();
            }
            ds.Dock = System.Windows.Forms.DockStyle.Fill;
            panel2.Controls.Add(ds);
            ds.RaiseCustomEvent += del;
            return ds;
        }

        public BaseDeviceMonitor loadMonitor(BaseDeviceMonitor ds, Panel panel2, EventHandler del)
        {
            panel2.Controls.Remove(ds);
            if (GlobalConstants.type == "0")
            {
                ds = new DeviceMonitor();

            }
            else if (GlobalConstants.type == "1")
            {
                ds = new Device2Monitor();
            }
            ds.Dock = System.Windows.Forms.DockStyle.Fill;
            panel2.Controls.Add(ds);
            ds.RaiseCustomEvent += del;
            return ds;
        }

        public void alert(string msg)
        {
            DialogResult MsgBoxResult;//设置对话框的返回值
            MsgBoxResult = MessageBox.Show(msg,//对话框的显示内容
            "提示",//对话框的标题
            MessageBoxButtons.OK,//定义对话框的按钮，这里定义了YSE和NO两个按钮
            MessageBoxIcon.Exclamation,//定义对话框内的图表式样，这里是一个黄色三角型内加一个感叹号
            MessageBoxDefaultButton.Button1);//定义对话框的按钮式样
        }
    }
}
